package lang3;

import org.apache.commons.lang3.RandomStringUtils;

/**
 * @ClassName: RandomStringUtil
 * @Author: liugui
 * @Date: 2020-07-14 17:23
 **/
public class RandomStringUtil {
    public static void main(String[] args) {

        int n = 3;
        //随机生成n位数数字
        String string = RandomStringUtils.randomNumeric(n);
        System.out.println("随机生成"+n+"位数数字:" + string);
        //在指定字符串中生成长度为n的随机字符串
        String str = RandomStringUtils.random(n, "abcdefghijk");
        System.out.println("随机字符串:" + str);
        //指定从字符或数字中生成随机字符串
        System.out.println(RandomStringUtils.random(n, true, false));
        System.out.println(RandomStringUtils.random(n, false, true));
    }


}
